﻿@model Inovout.YunYao.Models.MonitoringNode
<div class="w50">
    @Model.Name
</div>
<div class="w50">
    数据：<input type="text" id="data" /><br />
    次数：<input type="text" id="time" value="1" /><br />
    等待时间：<input type="text" id="delay" value="1" />秒<br />
    <button id="post" onclick="postdata();">提交</button>
</div>
<script type="text/javascript">
    function postdata() {
        // http://localhost/node/receive -H "token:t1" -H "appkey:ak1" -d "node=1112001&value=22&timestamp=12233232"
        var node = "@Model.Code";
        var appkey = "@Model.Solution.Code";
        var token = "@ViewBag.Token";
        var timestamp = new Date().valueOf();
        var value = $("#data").val();
        if (!value) {
            alert("数据不能为空！");
            return;
        }
        var time = $("#time").val();
        var delay = $("#delay").val();
        var request = $.ajax({
            url: "@Url.Action("PostNode")",
            type: "post",
            data: {
                node: node,
                value: value,
                timestamp: timestamp,
                appkey: appkey,
                token: token
            },
            dataType: 'text',
        });
            request.done(function (msg) {
                alert(msg);
            });
            request.fail(function (jqXHR, textStatus) {
                debugger
                alert("Request failed: " + textStatus + "ErrorMsg:" + jqXHR.responseText);
            });
        }
</script>
